﻿--Project: Movie Site
--Team3: Darya, Derrick, Olavo 

CREATE PROCEDURE dbo.InsertNewAddress (@accountID int, @street varchar(50), @streetNum int, @aptNum varchar(15), @city varchar(50),
@state varchar(50), @country varchar(50), @zipCode varchar(50), @poBox int)

AS
DECLARE
@addressID as int

INSERT INTO Address
	(addressStreetName,
	 addressStreetNum,
	 addressAptNum,
	 addressCity,
	 addressState,
	 addressCountry,
	 addressZipCode,
	 addressPOBox)
 VALUES
	(@street,
	 @streetNum,
	 @aptNum,
	 @city,
	 @state,
	 @country,
	 @zipCode,
	 @poBox)

SET	@addressID = (SELECT MAX(addressID) FROM Address)
	
INSERT INTO AccountAddresses
	(accountID, addressID)
VALUES
	(@accountID, @addressID)
	
RETURN